home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / comms / other / ftransapiv1.3 / arexx / ftransaweb.awebrx < prev    next >
Text File  |  1999-11-30  |  4KB  |  144 lines

  1. /* 
  2.  ----------------------------------------
  3.  Aweb Translator By FTranslator Client  
  4.  
  5.  Script by Cristian Robert Gallas
  6.  
  7.  Tested with AWeb 3.2
  8.  Usage:                                 
  9.  Use in ARexx interface of Aweb         
  10.  $VER: FTransAWEB.awebrx v1.2 (25.09.99)
  11.  ----------------------------------------
  12.  
  13.  HISTORY
  14.  ----------------------------------------
  15.  v0.01b [12.08.98] - First public beta version.
  16.  v1.0   [01.05.99] - Added new features.
  17.  v1.1   [27.07.99] - Added ClearSelection.
  18.  v1.2   [25.09.99] - Modified to FTrans 1.2 API;
  19.                    - Added support to translate current frame;
  20.                    - Added support to translate popuplink frame;
  21.  ----------------------------------------
  22.  
  23.  [Steps installation]
  24.  
  25.  > Copy FTransAWEB.awebrx to AWEB3:Plugins/
  26.  > Go to AWeb/Settings/GUI Setting
  27.  > Select folder AREXX
  28.  > Click in ADD
  29.  > Title    -> [Port->Eng] (Example: Portuguese to English)
  30.  > Shortcut -> Choice
  31.  > Macro    -> AWeb3:Plugins/FTransAWEB.awebrx 3 (3 is a translation direction)
  32.  > Select text for translation
  33.  > Go to AREXX Menu and select [Port->Eng]
  34.  > Wait for windows with translation :)
  35.  
  36.  ARGS of script
  37.  FTransAWEB.awebrx [ARG1] [ARG2]
  38.  
  39.  [ARG1] - Translation direction
  40.  
  41.  0 - English   to Francais
  42.  1 - English   to Deutsch
  43.  2 - English   to Italiano
  44.  3 - English   to Portugues
  45.  4 - English   to Espanol
  46.  5 - Francais  to English
  47.  6 - Deutsch   to English
  48.  7 - Italiano  to English
  49.  8 - Espanol   to English
  50.  9 - Portugues to English
  51.  X - To open a request about direction
  52.  
  53.  [ARG2] - %u to send the url to translate or [ALL] to get current
  54.  
  55. */
  56.  
  57. Options Results
  58.  
  59. tmpfile = "Ram:FTransTmp.AWEB"
  60. tmpclip = "Ram:FTransAWeb.Clip"
  61. sel     = ""
  62. u_aweb  = ""
  63.  
  64. Parse Arg traduz u_aweb
  65.  
  66. u_aweb = space(u_aweb)
  67.  
  68. /* TESTA SE PODE SER USADAS AS LIBS DO AREXX */
  69. if ~show(l, "rexxsupport.library") then
  70.     if ~addlib("rexxsupport.library", 0, -30) then
  71.   exit
  72.  
  73. /* TESTA SE O PROGRAMA JA NAO ESTA COM A PORTA DE TRADUCAO ABERTA */
  74. if exists(tmpfile) then do
  75.   janela('"FTranslation port is open! Translation in progress, wait..." "_Ok"')
  76.   exit
  77. end
  78.  
  79. /* COLOCA COMO DEFAULT PORTUGUES TO ENGLISH */
  80. if traduz == '' | traduz == 'X' then do
  81.   traduz = requestaweb('"Select your translate direction:*N 1) English   to Francais*N 2) English   to Deutsch*N 3) English   to Italiano*N 4) English   to Portugues*N 5) English   to Espanol*N 6) Francais  to English*N 7) Deutsch   to English*N 8) Italiano  to English*N 9) Espanol   to English*N10) Portugues to English" "1|2|3|4|5|6|7|8|9|10|Quit"')
  82.   if(traduz = 0) then
  83.     exit
  84.   traduz = traduz - 1
  85. end
  86.  
  87. /* TRADUZ URL INTEIRA */
  88. if u_aweb ~== '' then do
  89.   if u_aweb == 'ALL' then
  90.     'GET URL VAR u_aweb'
  91.  
  92.   comando = 'C:FTranslator -u 'u_aweb' -d 'traduz' -o "Ram:FTransAweb.html" SILENCE NOFILTERS'
  93.   Address Command comando
  94.   'NEW URL file://localhost/ram:FTransAweb.html'
  95.   delay(100)
  96.   delete("ram:FTransAweb.html")
  97.   exit
  98. end
  99.  
  100. 'GET SELECTION VAR sel'
  101.  
  102. /* TESTA SE FOI MARCADO O TEXTO */
  103. if sel == '' then do
  104.   janela('"You need select text first..." "_Ok"')
  105.   exit
  106. end
  107.  
  108. /* SALVA CONTEUDO MARCADO NO ARQUIVO TEMPORARIO */
  109. call open(1, tmpclip, 'W')
  110. call writeln(1, sel)
  111. call close(1)
  112.  
  113. /* EXECUTA O FTRANSLATOR COM OS ARGUMENTOS DA TRADUCAO */
  114. CLEARSELECTION
  115. comando = 'C:FTranslator -f "'tmpclip'" -d 'traduz' SILENCE > 'tmpfile
  116. Address Command comando
  117. delete(tmpclip)
  118.  
  119. goodopen=open(1, tmpfile, 'R')
  120. linein = ''
  121. if goodopen then do
  122.   do until eof(1)
  123.     linein = linein'*N 'readln(1)
  124.   end
  125. end
  126. close(1)
  127.  
  128. delete(tmpfile)
  129.  
  130. janela('" 'linein' " "_Ok"')
  131. exit
  132.  
  133. janela:
  134.   parse arg reqchd
  135.   Request '"Freedom Translator"' reqchd
  136.   reqchd=result
  137. return(reqchd)
  138.  
  139. requestaweb:
  140.   parse arg reqchd
  141.   Request '"Freedom Translator"' reqchd
  142.   reqchd=result
  143. return(reqchd)
  144.